<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-yellow sidebar-mini">
<section class="content-header">
    <div id="toolbar" class="form-inline" style="margin-top: 20px">
        <a id="btn_notRead" href="javascript:void(0);" shiro:hasPermission="conInstall:creins:edit"
           class="btn btn-success pull-right" style="margin-right: 10px" onclick="saveAll()">
            <span class="Bold">保存</span>
        </a>
    </div>
    <h1></h1>
</section>
<section class="content">
    <!--<div class="col-xs-10 col-xs-offset-1" style="font-size: 14px;line-height: 200%;">-->
        <!--<img th:src="@{/img/logo3.jpg}" width="100px" height="100px" style="margin-top: -30px">-->
        <!--<div style="display: inline-block;margin-top: 5px;margin-left: 60px;font-size: 30px" align="center">-->
            <!--<span style="letter-spacing: 24px;display: block;line-height: 60px">&nbsp;辽宁忠旺机械设备制造有限公司</span>-->
            <!--<span style="display: block;font-size: 20px;line-height: 30px;">Liaoning Zhongwang Machinery Equipment Manufacturing Co., Ltd</span>-->
        <!--</div>-->
        <!--<div class="col-xs-10 col-xs-offset-1"-->
             <!--style="display: inline-block;margin-top: 5px;margin-left: 60px;font-size: 40px" align="center">-->
            <!--<span style="letter-spacing: 24px;display: block;line-height: 60px">&nbsp;安装派工单</span>-->
        <!--</div>-->
    <!--</div>-->
    <div class="box-body" style="margin-top: 50px">
        <form id="sheetForm" class="form-horizontal bg-white">
            <!--<div class="col-md-6 col-xs-offset-1">-->
                <!--<div class="col-md-12 form-group ">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:100px;padding-right: 0px;padding-left: 10px;">生产订单编号</label>-->
                    <!--<label class="control-label" col-md-8 style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="prodNo" type="text" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group ">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:100px;padding-right: 0px;padding-left: 10px;">项目编号</label>-->
                    <!--<label class="control-label" col-md-8 style="text-align: left;padding-left: 5px;">-->
                        <!--<select id="sheetForm-proCode" style="width:300px" class="form-control"-->
                                <!--name="proCode"></select>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group ">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:100px;padding-right: 0px;padding-left: 10px;">需方</label>-->
                    <!--<label class="control-label" col-md-8 style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="customer" type="text" class="form-control"-->
                               <!--id="sheetForm-customer" readonly="readonly"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group ">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:100px;padding-right: 0px;padding-left: 10px;">安装数量</label>-->
                    <!--<label class="control-label" col-md-8 style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="installNum" type="number" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group ">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:100px;padding-right: 0px;padding-left: 10px;">设计负责人及联系方式</label>-->
                    <!--<label class="control-label" col-md-8 style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="designLeader" type="text" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group ">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:100px;padding-right: 0px;padding-left: 10px;">安装需求</label>-->
                    <!--<label class="control-label" col-md-8 style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="installationRequirements" type="text" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
            <!--</div>-->

            <!--<div class="col-md-4">-->
                <!--<div class="col-md-12 form-group">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:90px;padding-right: 0px;padding-left: 10px;">订单数量</label>-->
                    <!--<label class="control-label" style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="prodNum" type="text" class="form-control"-->
                               <!--id="sheetForm-proNum" readonly="readonly"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:90px;padding-right: 0px;padding-left: 10px;">项目名称</label>-->
                    <!--<label class="control-label" style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="proName" type="text" class="form-control"-->
                               <!--id="sheetForm-proName" readonly="readonly"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:90px;padding-right: 0px;padding-left: 10px;">安装地点</label>-->
                    <!--<label class="control-label" style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="installPlace" type="text" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:90px;padding-right: 0px;padding-left: 10px;">项目负责人及联系方式</label>-->
                    <!--<label class="control-label" style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="projectLeader" type="text" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
                <!--<div class="col-md-12 form-group">-->
                    <!--<label class="control-label"-->
                           <!--style="text-align: left;width:90px;padding-right: 0px;padding-left: 10px;">出厂编号</label>-->
                    <!--<label class="control-label" style="text-align: left;padding-left: 5px;">-->
                        <!--<input style="width: 300px" name="factoryNumber" type="text" class="form-control"/>-->
                    <!--</label>-->
                <!--</div>-->
            <!--</div>-->
            <div class="col-xs-11 col-xs-offset-1">
                <table class="t1 t3" id="hoursTable">
                    <thead>
                    <tr>
                        <td colspan="9">
                            <img th:src="@{/img/logo3.jpg}" width="64px" height="40px" style="margin-top: -20px">
                            <div style="display: inline-block;margin-top: 5px;margin-left: 20px">
                                <span style="letter-spacing: 24px;display: block;line-height: 20px">&nbsp;辽宁忠旺机械设备制造有限公司</span>
                                <span style="display: block;font-size: 12px;line-height: 20px">Liaoning Zhongwang Machinery Equipment Manufacturing Co., Ltd</span>
                            </div>
                        </td>
                        <td colspan="1"  style="width: 9%;font-size: 20px;">安装派工单</td>
                        <td colspan="1"  style="width: 9%"></td>
                    </tr>
                    <tr>
                        <td style="width: 5%">生产令号</td>
                        <td colspan="1" style="width: 12%;font-size: 14px;">
                            <select id="sheetForm-proCode" class="form-control" name="proCode"></select>
                        </td>
                        <td style="width: 9%">项目名称</td>
                        <td colspan="2" style="width: 18%">
                            <input id="proName" type="text" class="form-control" name="proName" readonly>
                        </td>
                        <td style="width: 5%">订单数量</td>
                        <td colspan="1" style="width: 5%">
                            <input id="proNum" type="number" class="form-control" name="prodNum" readonly>
                        </td>
                        <td style="width: 9%">出厂编号</td>
                        <td colspan="2" style="width: 18%">
                            <input  type="text" class="form-control" name="factoryNumber" >
                        </td>
                        <td  colspan="1"  style="width: 9%"></td>
                    </tr>
                    <tr>
                        <td style="width: 5%">需方</td>
                        <td colspan="3" style="width: 15%;font-size: 14px;">
                            <input id="customer" class="form-control" name="customer" readonly>
                        </td>
                        <td style="width: 8%">安装地点</td>
                        <td colspan="3" style="width: 12%">
                            <input id="installPlace" type="text" class="form-control" name="installPlace" >
                        </td>
                        <td style="width: 8%">安装数量</td>
                        <td colspan="1" style="width: 8%">
                            <input id="installNum" type="number" class="form-control" name="installNum" >
                        </td>
                        <td  colspan="1"  style="width: 9%"></td>
                    </tr>
                    <tr>
                        <td style="width: 12%">项目负责人及电话</td>
                        <td colspan="4" style="width: 15%;font-size: 14px;">
                            <input id="projectLeader" class="form-control" name="projectLeader">
                        </td>
                        <td style="width: 12%">设计负责人及电话</td>
                        <td colspan="4" style="width: 12%">
                            <input id="designLeader" type="text" class="form-control" name="designLeader" >
                        </td>
                        <!--<td style="width: 10%">生产订单编号</td>-->
                        <!--<td colspan="1" style="width: 12%">-->
                            <!--<input id="prodNo" type="text" class="form-control" name="prodNo" >-->
                        <!--</td>-->
                        <td  colspan="1"  style="width: 9%"></td>
                    </tr>
                    <tr>
                        <td style="width: 10%">安装需求</td>
                        <td colspan="9" style="width: 80%;font-size: 14px;">
                            <input id="installationRequirements" class="form-control" name="installationRequirements">
                        </td>
                        <td  colspan="1"  style="width: 9%"></td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td style="width: 6%">类型</td>
                        <td colspan="2" style="width: 15%">安装负责人</td>
                        <td colspan="2" style="width: 15%">要求完成日期</td>
                        <td colspan="5" style="width: 20%">备注</td>
                        <td  colspan="1"  style="width: 9%"></td>
                    </tr>
                    <tr>
                        <td colspan="1" style="width: 6%">
                            <input type="text" class="form-control" name="special" autocomplete="off" value="机械"
                                   readonly>
                        </td>
                        <td colspan="2" style="width: 15%">
                            <input type="text" class="form-control" name="installPrincipal" autocomplete="off">
                        </td>
                        <td colspan="2" style="width: 15%">
                            <input type="text" class="form-control datepicker" name="installTime"
                                   readonly="readonly" style="width: 100%;"/>
                        </td>

                        <td colspan="5" style="width: 20%">
                            <input type="text" class="form-control" name="installRemark" autocomplete="off">
                        </td>
                        <td style="font-size: 16px;">
                            <span class="card-del" title="删除"><i class="fa fa-remove text-red"></i> </span>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="1" style="width: 6%">
                            <input type="text" class="form-control" name="special" autocomplete="off" value="流体"
                                   readonly>
                        </td>
                        <td colspan="2" style="width: 15%">
                            <input type="text" class="form-control" name="installPrincipal" autocomplete="off">
                        </td>
                        <td colspan="2" style="width: 15%">
                            <input type="text" class="form-control datepicker" name="installTime"
                                   readonly="readonly" style="width: 100%;"/>
                        </td>

                        <td colspan="5" style="width: 20%">
                            <input type="text" class="form-control" name="installRemark" autocomplete="off">
                        </td>
                        <td style="font-size: 16px;">
                            <span class="card-del" title="删除"><i class="fa fa-remove text-red"></i> </span>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="1" style="width: 6%">
                            <input type="text" class="form-control" name="special" autocomplete="off" value="自动化"
                                   readonly>
                        </td>
                        <td colspan="2" style="width: 15%">
                            <input type="text" class="form-control" name="installPrincipal" autocomplete="off">
                        </td>
                        <td colspan="2" style="width: 15%">
                            <input type="text" class="form-control datepicker" name="installTime"
                                   readonly="readonly" style="width: 100%;"/>
                        </td>

                        <td colspan="5" style="width: 20%">
                            <input type="text" class="form-control" name="installRemark" autocomplete="off">
                        </td>
                        <td style="font-size: 16px;">
                            <span class="card-del" title="删除"><i class="fa fa-remove text-red"></i> </span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </form>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table, table1, table2;
    /**添加明细选择按钮*/
    js.select2({
        id: 'sheetForm-proCode',
        placeholder: '',
        ajax: {

            url: function () {
                return ctx + 'create/shipments/project/list'
            },
            processResults: function (data, page) {
                let array = data;
                for (let i = 0; i < data.length; i++) {
                    array[i]["proId"] = array[i]['proId'];
                    array[i]["id"] = array[i]['proCode'];
                    array[i]["text"] = array[i]['proCode'];

                }
                return {results: array};
            },
        }
    });
    /** 项目编号下拉框选中 */
    $("#sheetForm-proCode").on("select2:select", function () {
        debugger
        var aa = $(this).select2("data")[0].proName;
        $("#proName").val($(this).select2("data")[0].proName);
        $("#customer").val($(this).select2("data")[0].customer);
        $("#proId").val($(this).select2("data")[0].proId);
        $("#proCode").val($(this).select2("data")[0].proCode);
        $("#proNum").val($(this).select2("data")[0].proQty);
    });

    /** 保存 */
    function saveAll() {
        let res = js.vd({
            id: 'sheetForm',
            notEmpty: ['prodNo', 'proCode', 'installNum', 'designLeader', 'installationRequirements', 'installPlace'
                , 'projectLeader', 'factoryNumber', 'installPrincipal', 'installTime', 'isDebugging']
        })
        if (!res) {
            return;
        }
        var url = ctx + "create/dispatching/addDispatching";
        js.validSubmit({
            formId: "sheetForm",
            url: url,
            data: new FormData($("#sheetForm")[0]),
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    location.href= ctx +"create/dispatching/submit";
                } else {
                    js.modal.warning(result.msg);
                }
            }
        });
    }
    /** 删除行 */
    $('#sheetForm').on('click', '.card-del', function () {
        if ($("table tbody tr").length > 2) {

            $(this).parents("tr").remove();
        }
    });
    $(function () {

    });

</script>
</body>
</html>